package topday1_9.demo4;

/**
 * @Auther:小陈的Java
 * 重写toString方法 ，表示对象的属性内容
 */
public class Tostring {
    public static void main(String[] args) {
        User user = new User(1,"小红");
        System.out.println(user);
        System.out.println(user.toString());
    }
}
class User2{
    private int id;
    private String name;
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public User2(int id, String name) {
        this.id = id;
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public User2() {
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }
}
